foreach and forelse empty

45

@foreach ($products as $item)
     <tr>
         <th>{{ $item->id }}</th>
         <td>{{ $item->title }}</td>
         <td>${{ number_format($item->price,2) }}</td>
         <td>{{ $item->cat->title }}</td>
     </tr>
     @if($item->price > 15) @break @endif
 @endforeach
 
 //-------
 @forelse ($products as $item)
     <tr>
         <th>{{ $item->id }}</th>
         <td>{{ $item->title }}</td>
         <td>${{ number_format($item->price,2) }}</td>
         <td>{{ $item->cat->title }}</td>
     </tr>
 @empty
     <div class="alert alert-danger">No Products Added</div>
 @endforelse

Comments

Submit
0 Comments